package day4;

import java.util.*;

/**
 * ClassName：TestMapStudent
 *
 * @Author：小鱼
 * @Create：2025-08-14 10:28
 */
public class TestHashtable {
    public static void main(String[] args) {
        Map<Student,String> map = new Hashtable<>();

        map.put(new Student("zs",18),"001");
        map.put(new Student("ls",20),"003");
        map.put(new Student("ww",18),"009");
        map.put(new Student("ww",18),"005");
        //map.put(null,"010");
        //map.put(new Student("ww",18),null);
        System.out.println("长度："+map.size());
        System.out.println("map: "+map);

        //遍历方法一
        Set<Student> set = map.keySet();
        System.out.println(set);
        for (Student i:set) {
            System.out.println(map.get(i));
        }
        //遍历方法二
        Collection<String> coll =map.values();
        for (String s: coll) {
            System.out.println(s);
        }


        //遍历方法三
        Set<Map.Entry<Student,String>> entries = map.entrySet();
        System.out.println("entries:"+entries);
        for (Map.Entry<Student, String> entry : entries) {
            entry.setValue("hi");
            System.out.print(entry.getKey()+"-");
            System.out.println(entry.getValue());
        }

    }
}
